package com.freewater.javabase.demo.designpattern.command2.undowithstatus.client;

import com.freewater.javabase.demo.designpattern.command2.undowithstatus.command.*;
import com.freewater.javabase.demo.designpattern.command2.undowithstatus.invoker.RemoteControllerWithUndo;
import com.freewater.javabase.demo.designpattern.command2.undowithstatus.receiver.CellingFan;

/**
* 客户端
* Created by FreeWater on 2017/4/4.
*/
public class RemoteControllerTest {
	public static void main(String[] args) {
		CellingFan cellingFan = new CellingFan("Living room");

		CellingFanHighCommand highCommand = new CellingFanHighCommand(cellingFan);
		CellingFanMediumCommand mediumCommand = new CellingFanMediumCommand(cellingFan);
		CellingFanLowCommand lowCommand = new CellingFanLowCommand(cellingFan);
		CellingFanOffCommand offCommand = new CellingFanOffCommand(cellingFan);

		RemoteControllerWithUndo remoteControllerWithUndo = new RemoteControllerWithUndo();
		remoteControllerWithUndo.setCommand(0, mediumCommand, offCommand);
		remoteControllerWithUndo.setCommand(1, highCommand, offCommand);

		remoteControllerWithUndo.onButtonWasPressed(0);
		remoteControllerWithUndo.offButtonWasPressed(0);
		remoteControllerWithUndo.undoButtonWasPressed();

		remoteControllerWithUndo.onButtonWasPressed(1);
		remoteControllerWithUndo.undoButtonWasPressed();
	}
}
